package com.kfm.pm;

public class Mouse extends DianZi implements Usb  {

    // 重写：方法名相同，参数列表相同，返回类型一致，访问修饰符相同或变大，异常相同或缩小
    @Override
    public void chuanShu() {
        System.out.println("鼠标开始运行");
    }


    public void chongDian() {
        System.out.println("鼠标充电");
    }

    @Override
    public void typing() {

    }
}


class Test {
    public static void main(String[] args) {
        //
        Usb usb = new Mouse();
        Usb usb1 = new KeyBoard();
//        if (usb instanceof Mouse) {
//            Mouse mouse = (Mouse) usb;
//            mouse.chongDian();
//        }

        // JDK 16
        if (usb instanceof Mouse mouse) {
            mouse.chongDian();
        }
        usb.chuanShu();
        usb1.chuanShu();
    }
}
